/**
 * 远光ECP平台3.0版本 http://www.ygsoft.com/ Grace [Gris Application Cloud-Computing
 * Extension]
 * Copyright(c) 1998 - 2020 YGSoft.Inc, All Rights Reserved
 * 
 * ecp.component.simpleUpload.js
 * 
 * 单个项目上传控件
 * 
 * 占位符，例如：
 * <div class="input-prepend input-group" style="width:30%">
 *	<input id="attachment" data-option="{"resId":"daf12ddf98s0sf43lfsf090"}" class="form-control attachment-input">
 *	<span class="add-on input-group-addon">
 *		<i class="glyphicon attachment-i">...</i>
 *	</span>
 * </div>
 * 
 * 变更版本：
 * Created by zhengxianwei@ygsoft.com 2016-07-13
 */

define(["jquery","ecp.utils","ecp.component.upload","ecp.utils.i18n"],function(t,o,n,e){var i={webuploader:{pick:{multiple:!1}}},r=function(t,o){t&&0!==t.length&&(this.init(t,o),this.render())};return r.prototype={init:function(o,n){if(!o||0===o.length)return void(window.console&&window.console.error(e.upload.notcontrol));this.control=o;var r=o.attr("data-option");r=r&&0!==r.length?t.parseJSON(r):{},this.option=t.extend(!0,{},i,n,r)},render:function(){this.upload=this.control.ecpUploader(this.option)},value:function(t){var o=this,n=o.control;return arguments.length>0?void o.initValue(t):n.val()},initValue:function(t){0!==arguments.length&&(this.control.val(t),this.option.resId=t)},readOnly:function(){this.control.attr("readOnly","readOnly")},removeReadOnly:function(){this.control.removeAttr("readOnly")},disable:function(){this.control.attr("disabled",!0),this.upload&&(this.upload.disable=!0,this.upload.control&&this.upload.control.next().css("cursor","default"))},enable:function(){this.control.removeAttr("disabled"),this.upload&&(this.upload.disable=!1,this.upload.control&&this.upload.control.next().css("cursor","pointor"))},setYwKey:function(t){this.upload.setYwKey(t)},getYwKey:function(){return this.upload.getYwKey()}},function(t){var o=t.fn.simpleUploader;t.fn.simpleUploader=function(o){var n=this;o=o||{};var e=typeof o;if("object"===e){var i=[];return this.each(function(){var n=t.extend({},o,!0),e=new r(t(this),n);this.simpleUploader=e,i.push(e)}),1===i.length&&(i=i[0]),i}if("string"===e){var l=Array.prototype.slice.call(arguments,1);if(r.prototype[o])return r.prototype[o].call(l)}else if(o===!0)return n[0]&&n[0].simpleUploader},t.fn.simpleUploader.Constructor=r,t.fn.simpleUploader.noConflict=function(){return t.fn.simpleUploader=o,this}}(jQuery),r.prototype});